% compute_gould_wshf5m
% compute_gould_wshf5m computes 5-min wind
% stress and heat flux time series using 
% the 5-min basic data in gould_met5m.
% 4/11/01

clear
load gould_met5m
sst=gapfil(sst); % fill nan holes 
% gould sensor heights
zr=29;zt=zr;zq=zr; 
% compute air-sea fluxes
A=hfbulktc(ws,zr,at,zt,rh,zq,bp,sst);
qsen=A(:,1);
qlat=A(:,2);
stress=A(:,4);
disp(['air-sea fluxes done'])
% compute sw flux
yr=2001*ones(size(t));
lat=y;long=-x; %west is positive,east is negative
[qsw,alb]=swhf(t-1,yr,long,lat,sw);
[sunalt,sorad]=soradna1(t-1,2001,long,lat);
disp(['shortwave flux is done'])
% compute lw
qlw=lwhf(sst,lw);
disp(['longwave flux is done'])
% net heat flux
qnet=qsw+qlw+qsen+qlat;

% save back in gould_met5m
save bob qnet qsw qlw qlat qsen stress sunalt sorad
clear
load gould_met5m
load bob
save gould_met5m
delete('bob.mat')
